function editAdminArea(){
	$.fn.tree.getSelect();
	var id=$.fn.tree.tmpid;
	var level=getLevel();
	var areaName=getName();
	var areaCode=getCode();
	var areaDesc=getDesc();
	if(id==undefined || id=="" || id=="0" || id==0){
		easyDialog.open({
			container:{
				header:"温馨提示",
				content:"请选择要编辑的区域！"
			},
			autoClose : 2000
		});
		return;
	}
	var token=localStorage.getItem("token");
	$('#administrtionOutTree').remove();
	$.ajax({
		url:server_url+'areaManager/editAdminTreeStep1.do?ran='+Math.random()+'&token='+token,
		type:'get',
		data: {id:id,level:level},
		success:function(data){
			var html='<div class="z_rightMidden">'
				+'<div class="z_title">首页>行政区域管理>编辑区域</div>'
				+'<div class="l_system">'
				+'<ul>'
				+'<li class="clearfix">'
				+'<span>区域名称</span>'
				+'<input maxlength="30" type="text" id="areaName" onkeyup="checkAreaName();" value="'+areaName+'"/>'
				+'<em>*</em>'+'<em id="tishi" style="margin:0px 0 0 0px;"></em>'
				+'</li>'
				+'<li class="clearfix">'
				+'<span>地区</span>'
				+'<div class="l_adress">';
			if(level==1||level==2||level==3||level==4||level==5||level==6){
				//只选中中国下
				html+='<span>中国</span>';
			}
			if(level==2||level==3||level==4||level==5||level==6){
				//选择省下
				html+='<em>></em><span>'+data.data.shengName+'</span>';
			}
			if(level==3||level==4||level==5||level==6){
				//选择市下
				html+='<em>></em><span>'+data.data.shiName+'</span>';
			}
			if(level==4||level==5||level==6){
				//选择县下
				html+='<em>></em><span>'+data.data.xianName+'</span>';
			}
			if(level==5||level==6){
				//选择镇下
				html+='<em>></em><span>'+data.data.zhenName+'</span>';
			}
			if(level==6){
				//选择村下
				html+='<em>></em><span>'+data.data.cunName+'</span>';
			}
			html+='</div>'
				+'</li>'
				+'<li class="clearfix">'
				+'<span>区域代码</span>'
				+'<input type="text" value="'+areaCode+'" id="areaCode" maxlength="6" onkeyup="this.value=this.value.replace(/\\D/g,\'\')" onafterpaste="this.value=this.value.replace(/\\D/g,\'\')"/>'
				+'</li>'
				+'<li class="clearfix">'
				+'<span>备注</span>'
				+'<textarea name="" id="areaDesc" cols="30" rows="10" maxlength="100">'+areaDesc+'</textarea>'
				+'</li>'
				+'</ul>'
				+'<a href="javascript:editSubmit();" class="z_sure">确定</a>'
				+'<a href="javascript:returnList2();" class="z_goback">返回</a>'
				+'</div>'
				+'</div>';
			$('#administrtionTreeEdit').html(html);
		}
	});
}
function getId(){
	return $.fn.tree.getSelect();
};
function getParentId(){
	return $.fn.tree.obj_tu.parentId;
};
function getLevel(){
	return $.fn.tree.obj_tu.level;
};
function getName(){
	return $.fn.tree.obj_tu.areaName;
}
function getDesc(){
	return $.fn.tree.obj_tu.areaDesc;
}
function getCode(){
	return $.fn.tree.obj_tu.areaCode;
}



function editSubmit(){
	$.fn.tree.getSelect();
	var id=$.fn.tree.tmpid;
	var areaName=$("#areaName").val();
	var areaCode=$("#areaCode").val();
	var areaDesc=$("#areaDesc").val();
	var username=localStorage.getItem("username");
	var parentId=getParentId();
	var level=getLevel();
	var reg = /^([0-9.]+)$/;
	if(areaName=="" || areaName==undefined){
		$("#tishi").text("该值不能为空");
		return;
	}
	if(areaCode!=null && areaCode!="" && areaCode !=undefined){
		if(reg.test(areaCode) != true){
			easyDialog.open({
				container:{
					header:"温馨提示",
					content:"区域代码只能为数字！"
				},
				autoClose : 2000
			});
			return;
		}
		isExistAreaCode(id,areaCode);
	}
	var isExist = $("#isExist").val();
	if(isExist=="1"){
		easyDialog.open({
			container:{
				header:"温馨提示",
				content:"区域代码不能相同！"
			},
			autoClose : 2000
		});
		return;
	}
	var token=localStorage.getItem("token");
	$.ajax({
		url:server_url+'areaManager/editAdminTreeStep2.do?ran='+Math.random()+'&token='+token,
		type:'post',
		async:false,
		data: {id:id,parentId:parentId,level:level,areaCode:areaCode,areaDesc:areaDesc,areaName:areaName,username:username},
		success:function(data){
			back();
		}
	});
}
function returnList2(){
	back();
}
function back(){
	tl_config.loadToWorkArea("showAdminAreaPage.do?ran="+Math.random());
}